﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class AnswerLabel1 : MonoBehaviour {

	// Use this create number random array
	public static List<int> randomNumberList;

	// Set style for text label
	public Texture2D[] answerLabel;

	// Use this to save answer
	string answerString = null;

	// Use this for initialization
	void Start () {
		randomNumberList = new List<int> ();
		int count = 0;
		do{
			int chooseNumber = Random.Range(0, 2);
			randomNumberList.Add(chooseNumber);
			count ++;
		}while(count < 10);

	}
	
	// Update is called once per frame
	void Update () {
		
	}

	void OnGUI(){
		if (Program.isClicked == true && QuestionLabel.questionIndex < 10 && Program.isResultNotif == false) {
			if(randomNumberList[QuestionLabel.questionIndex] == 0){
				answerString = QuestionLabel.calculatorList [QuestionLabel.questionIndex].getCorrectAnswer ();
				if(answerString.Equals("+")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123, 
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[0], GUIStyle.none);
				}else if(answerString.Equals("-")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[1], GUIStyle.none);
				}else if(answerString.Equals("*")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[2], GUIStyle.none);
				}else{
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[3], GUIStyle.none);
				}

			}else{
				answerString = QuestionLabel.calculatorList [QuestionLabel.questionIndex].getInCorrectAnswer ();;
				if(answerString.Equals("+")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[0], GUIStyle.none);
				}else if(answerString.Equals("-")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[1], GUIStyle.none);
				}else if(answerString.Equals("*")){
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[2], GUIStyle.none);
				}else{
					GUI.Button (new Rect (gameObject.transform.position.x + Screen.width / 2 - 123,
					                      gameObject.transform.position.y + Screen.height - 63, 50, 50), answerLabel[3], GUIStyle.none);
				}
			}
		}
	}
}
